<?php
	header("Content-type: text/html;charset=utf8");
	require_once("../db/dbclass.php");
	require_once("../model/userinfo.php");
	require_once("../utils/common.php");
	require_once("../utils/config.php");
	$myDb=&DbController::getInstance();
	$myImg=new UpdateUserInfo();
	$result_obj=new UpdateUserInfo();
	$userId=$_POST['user_id'];
	$userWork=$_POST['user_work'];
	$userLocation=$_POST['user_location'];
	$userSex=$_POST['user_sex'];
	$userBirth=$_POST['user_birth'];
	$userSign=$_POST['user_sign'];
	$userNickname=$_POST['user_nickname'];
	$user_hobbies=new test2();					//php模拟用的
	$userHobbies=json_encode($user_hobbies);	//php模拟用的
	$userHobbies=json_decode($userHobbies);		//php模拟用的
	// $userHobbies=$_POST['user_hobbies'];		//一个兴趣爱好的json对象			//androi测试用的
	getFile("uploadedfile",$userId,$myImg,2);
	if($myImg->result=="TRUE"){
		$param1="";
		if($myImg->img_url==""){
			$param1="UPDATE yj_user_info SET user_work= '$userWork',user_sign='$userSign',user_sex='$userSex',user_birth='$userBirth',user_location='$userLocation',user_nickname='$userNickname' WHERE user_id='$userId'";
		}
		else{
			$param1="UPDATE yj_user_info SET user_work= '$userWork',user_sign='$userSign',user_sex='$userSex',user_birth='$userBirth',user_location='$userLocation',user_nickname='$userNickname',user_photo='$myImg->img_url' WHERE user_id='$userId'";
		}
		$result1=$myDb->exec_query($param1); //更新user_info表
		$result2=hobby_insert($myDb,$userHobbies,$userId);
		if($result1 && $result2){
			$result_obj->result= "success" ;
			if($myImg->img_url==""){
				
			}else{
				$result_obj->img_url=$result_obj->img_url.URL.substr($myImg->img_url,2);
			}
		}else{
			$result_obj->result="failure";
		}
	}
	else{
		$result_obj->result="failure";
	}
	$result_json = json_encode($result_obj);
	echo $result_json;
?>